﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Disk
    {
        private string brand;

        public string Brand { get => brand; set => brand = value; }

        public Disk(string brand)
        {
            this.brand = brand;
        }

        public Disk()
        {
        }


    }
    interface IUSB
    {
        void Read();
        void Write();
    }
    class Computer
    {
        private string brand;

        private IUSB usb1;
        private IUSB usb2;

        public Computer(string brand)
        {
            this.brand = brand;
        }

        public Computer()
        {
        }

        public string Brand { get => brand; set => brand = value; }
        internal IUSB Usb1 { get => usb1; set => usb1 = value; }
        internal IUSB Usb2 { get => usb2; set => usb2 = value; }


        public void Start()
        {
            Console.WriteLine("{0}电脑开机中", this.brand);
        }
        public void End()
        {
            Console.WriteLine("{0}电脑关机中", this.brand);
        }

        public void ReadData()
        {
            usb1.Read();
            usb2.Read();
        }

        public void WriteData()
        {
            usb1.Write();
            usb2.Write();
        }
    }
    class UDisk : Disk, IUSB
    {
        public void Read()
        {
            Console.WriteLine("{0}品牌的U盘在读取数据中...", this.Brand);
        }

        public void Write()
        {
            Console.WriteLine("{0}品牌的U盘正在写入数据中...", this.Brand);
        }

        public UDisk(string brand) : base(brand)
        {
        }
    }
    class MobileHardDisk : Disk, IUSB
    {
        public void Read()
        {
            Console.WriteLine("{0}品牌的移动硬盘在读取数据中...", this.Brand);
        }

        public void Write()
        {
            Console.WriteLine("{0}品牌的移动硬盘正在写入数据中...", this.Brand);
        }
        public MobileHardDisk(string brand) : base(brand)
        {

        }

    }
    class Program4
    {
        static void Main(string[] args)
        {
            UDisk u1 = new UDisk("金士顿64G");
            u1.Read();
            u1.Write();

            Console.WriteLine();

            MobileHardDisk m1 = new MobileHardDisk("三星500G");
            m1.Read();
            m1.Write();

            Console.WriteLine();

            Computer lenove = new Computer("联想");
            lenove.Start();
            lenove.Usb1 = u1;
            lenove.Usb2 = m1;

            lenove.ReadData();
            lenove.WriteData();

            lenove.End();
            Console.ReadKey();
        }
    }
}
